#ifndef ACAPELLA_SYNCHRONIZE_RW_LCOK_WINDOWS_H
#define ACAPELLA_SYNCHRONIZE_RW_LCOK_WINDOWS_H

#include <windows.h>

namespace acapella
{
namespace synchronize
{

class rw_lock
{
public:
	rw_lock()
	{
		InitializeSRWLock(&v_);
	}

	~rw_lock()
	{
	}

	int read_lock()
	{
		AcquireSRWLockShared(&v_);
		return 0;
	}

	int write_lock()
	{	
		AcquireSRWLockExclusive(&v_);
		return 0;
	}

	int read_unlock()
	{
		ReleaseSRWLockShared(&v_);
		return 0;
	}

	int write_unlock()
	{
		ReleaseSRWLockExclusive(&v_);
		return 0;
	}

private:
	SRWLOCK v_;

	rw_lock(const rw_lock&);
	rw_lock& operator=(const rw_lock&);
};

}
}


#endif
